package uds_fld

import (
	"server/global"
)


type UdsFld struct {
	global.BaseModel

	UdsTbId uint `json:"udsTbId" form:"udsTbId" gorm:"not null;column:udsTbId;comment:uds表id;size:100;"`

	ColName       string `json:"colName" form:"colName" gorm:"not null;column:colName;comment:字段名;size:100;"`
	ColDataType   string `json:"colDataType" form:"colDataType" gorm:"not null;column:colDataType;comment:数据类型;size:50;"`
	ColComment    string `json:"colComment" form:"colComment" gorm:"column:colComment;comment:字段注释;size:100;"`
	ColKey        bool   `json:"colKey" form:"colKey" gorm:"column:colKey;comment:是否主键;size:191;"`
	Unique        bool   `json:"unique" form:"unique" gorm:"column:unique;comment:是否唯一;size:100;"`
	NotNull       bool   `json:"notNull" form:"notNull" gorm:"column:notNull;comment:可否为空;size:100;"`
	AutoIncrement bool   `json:"autoIncrement" form:"autoIncrement" gorm:"column:autoIncrement;comment:是否自增;size:100;"`

	ColCharSet    string `json:"colCharSet" form:"colCharSet" gorm:"column:colCharSet;comment:字符集;size:191;"`
	ColType       string `json:"colType" form:"odsColType" gorm:"not null;column:odsColType;comment:ods列类型;size:191;"`
	ColDataLength string `json:"colDataLength" form:"colDataLength" gorm:"not null;column:colDataLength;comment:数据长度;size:50;"`
	ColLabel      string `json:"colLabel" form:"colLabel" gorm:"column:colLabel;comment:字段标签;size:50;"`

	Visible bool `json:"visible" form:"visible" gorm:"default:false;column:visible;comment:visible;size:50;"`

	Sort     int  `json:"sort" form:"sort" gorm:"column:sort;comment:排序;size:19;"`
	Selected bool `json:"selected" form:"selected" gorm:"-"`
	Remarks    string `json:"remarks" form:"remarks" gorm:"column:remarks;comment:备注;size:250;"`
	TimeFormat string `json:"timeFormat" form:"timeFormat" gorm:"column:timeFormat;comment:时间格式;size:50;"`
}


func (UdsFld) TableName() string {
	return "uds_fld"
}

func (m *UdsFld) Create() error {
	err := global.SysDB.Create(m).Error
	return err
}

func (m *UdsFld) Update() error {
	err := global.SysDB.Save(m).Error
	return err
}
